feat(server): Implement and document security group attach/detach commands#1341
feat(server): Implement and document security group attach/detach commands#1341
Conversation
…unction to ignore unused input arguments
Merging this branch will increase overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
| } | ||
|
|
||
| prompt := fmt.Sprintf("Are your sure you want to detach service account %q from a server %q?", model.ServiceAccMail, serverLabel) | ||
| prompt := fmt.Sprintf("Are you sure you want to detach service account %q from a server %q?", model.ServiceAccMail, serverLabel) |
There was a problem hiding this comment.
Typo fix (boyscout) - okay to keep in here?
| return fmt.Errorf("attach security group to server: %w", err) | ||
| } | ||
|
|
||
| params.Printer.Info("Attached security group %q to server %q\n", securityGroupLabel, serverLabel) |
There was a problem hiding this comment.
| params.Printer.Info("Attached security group %q to server %q\n", securityGroupLabel, serverLabel) | |
| params.Printer.Outputf("Attached security group %q to server %q\n", securityGroupLabel, serverLabel) |
This is often handled wrong in the codebase, that's why I'll explain it in detail. Please make sure to remember this in the future and especially look out for it in code reviews you will do in the future. 😅
Outputf prints to stdout, Info prints to stderr. See the code examples below for details.
Since this output here is a success message and no error message, it belongs into the stdout output from my perspective.
stackit-cli/internal/pkg/print/print.go
Lines 68 to 76 in 26bc5f1
stackit-cli/internal/pkg/print/print.go
Lines 107 to 114 in 26bc5f1
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.description, func(t *testing.T) { | ||
| p := print.NewPrinter() |
There was a problem hiding this comment.
stackit-cli/internal/pkg/testutils/testutils.go
Lines 14 to 26 in 26bc5f1
Please use this util funcs to save us the boilerplate code
| return fmt.Errorf("detach security group from server: %w", err) | ||
| } | ||
|
|
||
| params.Printer.Info("Detached security group %q from server %q\n", securityGroupLabel, serverLabel) |
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.description, func(t *testing.T) { | ||
| p := print.NewPrinter() |
Description
This PR implements the
stackit server security-group attachanddetachcommands.Changes
stackit server security-group attachto associate a security group with a server.stackit server security-group detachto remove a security group from a server.Testing Instructions
Confirm the security group appears in the server details.
Related Issues
Resolves #1216
relates to STACKITCLI-308
Checklist
make fmtmake generate-docs(will be checked by CI)make test(will be checked by CI)make lint(will be checked by CI)